/*页面跳转兜底js*/
/*外部提交*/
document.addEventListener("DOMContentLoaded", function () {
    const prevBtn = document.querySelector(".prevpage");
    const nextBtn = document.querySelector(".nextpage");
    const links = Array.from(document.querySelectorAll("a[href*='Blog']"));

    function getCurrentIndex() {
        return links.findIndex(link => link.classList.contains("on"));
    }

    function goToPage(index) {
        if (index >= 0 && index < links.length) {
            window.location.href = links[index].getAttribute("href");
        }
    }

    prevBtn.addEventListener("click", function (e) {
        e.preventDefault();
        let currentIndex = getCurrentIndex();
        let newIndex = currentIndex === 0 ? links.length - 1 : currentIndex - 1;
        goToPage(newIndex);
    });

    nextBtn.addEventListener("click", function (e) {
        e.preventDefault();
        let currentIndex = getCurrentIndex();
        let newIndex = currentIndex === links.length - 1 ? 0 : currentIndex + 1;
        goToPage(newIndex);
    });
});